package 力扣日常刷题.木23一月.第01天301;

/**
 * @author 帅小伙
 * @date 2022/3/1
 * @description
 */
public class Demo01数组中重复的数字 {


    public int findRepeatNumber(int[] nums) {
        int i = 0;
        while(i < nums.length) {
            //数字已对应索引
            if(nums[i] == i){
                i++;
                continue;
            }
            if (nums[nums[i]] == nums[i]) return nums[i];
            int t = nums[i];
            nums[i] = nums[t];
            nums[t] = t;
        }
        return -1;
    }
}
